package com.hong.controller;


import com.hong.service.impl.CreatePdfEchrtsAndTableMain3;
import com.itextpdf.text.DocumentException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.mapstruct.ap.shaded.freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@Slf4j
@Api(value = "pdf打印",tags = {"pdf打印"})
@RestController
@RequestMapping("pdf")
public class PdfController {

    @Autowired
    private CreatePdfEchrtsAndTableMain3 pdfEchrtsAndTableMain3;


    @ApiOperation("打印pdf")
    @GetMapping("print")
    public String printPdf(HttpServletResponse response){

        try {
            pdfEchrtsAndTableMain3.createPdfFile(response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (DocumentException e) {
            throw new RuntimeException(e);
        } catch (TemplateException e) {
            throw new RuntimeException(e);
        }

        return "OK";
    }





}
